<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>9-解构赋值</title>
</head>
<body>
    <script>
        //数组
        //语法：let ['变量1','变量2'] = [值1,值2];
        let [x,y,z] = [10,30];
        console.log(x);
        console.log(y);
        console.log(z);//undefined

        //对象
        var user = {
            username:'刘德华',
            age:55,
            amount:1000
        };
        //语法：let {'变量1','变量2'} = {值1,值2};
        let {username,age,amount} = user;
        console.log(username);
        console.log(age);
        console.log(amount);

        //另一种写法，解构时候给变量起了别名
        let {username:uName,age:uAge,amount:uAmount} = user; 
        console.log(uName);
        console.log(uAge);
        console.log(uAmount);




    </script>
</body>
</html>